clear all
set more off
set scheme s2color
cd ""

use "figureA11_data.dta", clear

* Calculate cumulative confirmed cases

keep if year == 2020 & month <= 6
bysort city_code (year month day): gen accum = sum(confn)
collapse (sum) accum, by(faction year month day)

bysort faction (year month day): gen time = _n
label define time 6 "Jan.15" 37 "Feb.15" 66 "Mar.15" 97 "Apr.15" 127 "May.15" 158 "Jun.15"
label values time time

#delimit ;
twoway (line accum time if faction == 1, color(green)) (line accum time if faction == 0, color(orange)),
        xlabel(6 37 66 97 127 158, valuelabel axis(1) labsize(small) tlength(0.8)) xscale(range(1 173))
        ylabel(0(2000)7000, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
        ytitle("Cumulative confirmed cases") xtitle("Date") legend(label(1 "With informal tie")
        label(2 "Without informal tie") position(4) ring(0) col(1) size(small))
        graphregion(fcolor(white) color(white) icolor(white) margin(small)) plotregion(margin(vsmall));
#delimit cr
